'use strict';
const dayjs = require("dayjs");
module.exports = app => {
    const { STRING, INTEGER, TINYINT } = app.Sequelize;
    return app.model.define(
      'plan',
      {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            company: INTEGER,
            name: STRING,
            start_time: {
                type: app.Sequelize.DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('start_time')).format('YYYY-MM-DD');
                }
            },
            end_time: {
                type: app.Sequelize.DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('end_time')).format('YYYY-MM-DD');
                }
            },
            type: STRING,
            count: INTEGER,
            status: INTEGER,
            version: INTEGER,
            is_deleted: TINYINT(1),
      },
      {
          tableName: 'production_plan',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: false, // 不想要 updatedAt
          createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
      }
  );
};
